actionPerformed()
actionPerformed()
The parameter for actionPerformed()
is a reference to an ActionEvent
object,
a subclass of AWTEvent
.
When a button is clicked,
actionPerformed()
is called with a new
ActionEvent
object
as a parameter.
So far,
we've not actually done anything with the
ActionEvent
object.
We will do this shortly.
Here is the picture:
The registered ActionListener
may be the object
that contains the button.
For small applications, this is an object
of a type that is a subclass of JFrame
.
(In other words, you define a class based
on JFrame
.)
The class contains the button
and also implements the ActionListener
interface.
In larger applications, the registered listener may be in a class by itself, or may be in some other container. See the following chapters.
Could a frame hold two buttons?